package elitech.vietnam.weatherfashion;

import java.util.ArrayList;
import java.util.List;

import android.app.Application;
import android.util.DisplayMetrics;
import elitech.vietnam.weatherfashion.badge.BadgeHelper;
import elitech.vietnam.weatherfashion.config.Utils;
import elitech.vietnam.weatherfashion.dto.FriendDTO;
import elitech.vietnam.weatherfashion.dto.Notify;
import elitech.vietnam.weatherfashion.dto.PostDTO;

public class WFApplication extends Application {

	private static WFApplication	mInstance;
	private int						mWidth			= 480;
	private int						mHeight			= 800;

	public boolean					mHideLocalNoti	= false;

	public List<PostDTO>			todayData;
	public List<List<PostDTO>>		weeklyData;
	public List<PostDTO>			stylerAllData;
	public List<PostDTO>			stylerFriendData;
	public List<PostDTO>			selfData		= new ArrayList<PostDTO>();
	public List<PostDTO>			heartData		= new ArrayList<PostDTO>();
	public List<FriendDTO>			userFriends;

	public List<Notify>				mListNoti		= new ArrayList<Notify>();

	public BadgeHelper				mBadge;

	private String					appDataDir;

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;
		mBadge = new BadgeHelper(this);
		initGlobalData();
	}

	@Override
	public void onLowMemory() {
		Utils.Log("Low Memory..");
		super.onLowMemory();
		System.gc();
	}

	public static WFApplication getInstance() {
		return mInstance;
	}

	private void initGlobalData() {
		appDataDir = getApplicationInfo().dataDir;

		DisplayMetrics display = getResources().getDisplayMetrics();
		mWidth = display.widthPixels;
		mHeight = display.heightPixels;

		weeklyData = new ArrayList<List<PostDTO>>();
		weeklyData.add(null);
		weeklyData.add(null);
		weeklyData.add(null);
		weeklyData.add(null);
		weeklyData.add(null);

		// File cacheDir = StorageUtils.getCacheDirectory(context);
		// AppUtils.Log(cacheDir.getAbsolutePath());
		// ImageLoaderConfiguration config = new
		// ImageLoaderConfiguration.Builder(context)
		// .denyCacheImageMultipleSizesInMemory()
		// .threadPoolSize(1)
		// .threadPriority(Thread.NORM_PRIORITY - 2)
		// .memoryCache(new WeakMemoryCache())
		// .defaultDisplayImageOptions(
		// new DisplayImageOptions.Builder()
		// .displayer(new FadeInBitmapDisplayer(200))
		// .cacheInMemory(false)
		// .cacheOnDisc(true)
		// .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
		// .bitmapConfig(Bitmap.Config.RGB_565)
		// .showImageForEmptyUri(R.drawable.loading_time)
		// .showImageOnFail(R.drawable.loading_time)
		// // .showStubImage(R.drawable.loading_time)
		// .build())
		// .discCacheFileNameGenerator(new Md5FileNameGenerator())
		// .discCache(new UnlimitedDiscCache(cacheDir))
		// .writeDebugLogs()
		// .build();
		// // Initialize ImageLoader with configuration.
		// ImageLoader.getInstance().init(config);

	}

	public String getDataDir() {
		return appDataDir;
	}

	public int getScreenWidth() {
		return mWidth;
	}

	public int getScreenHeight() {
		return mHeight;
	}
}
